# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 86
n 86(None)[self.get_marker_params = ('', {})
self._name = name
self.menu = None
self.list_owned = []
self._refresh()
return None
]:
	i: 58(), 76()
	o: 

nname: 76
n 76(None)[]:
	i: 35(f)
	o: 86()

nname: 58
n 58(None)[]:
	i: 47(t), 54()
	o: 86()

nname: 54
n 54(None)[]:
	i: 47(f)
	o: 58()

nname: 47
n 47(name)[]:
	i: 35(t)
	o: 54(f), 58(t)

nname: 35
n 35(universe != 'multiverse')[]:
	i: 21(), 34()
	o: 47(t), 76(f)

nname: 34
n 34(None)[]:
	i: 0(f)
	o: 35()

nname: 21
n 21(None)[self.universe = ''
]:
	i: 0(t)
	o: 35()

nname: 0
n 0(universe == 'multiverse')[self.universe = universe
]:
	i: 
	o: 21(t), 34(f)

nname: 86
n 86(None)[self.get_marker_params = ('', {})
self._name = name
self.menu = None
self.list_owned = []
self._refresh()
return None
]:
	i: 47(), 0(f)
	o: 

nname: 47
n 47(None)[if not name:
	pass
]:
	i: 0(t)
	o: 86()

nname: 0
n 0(universe != 'multiverse')[self.universe = universe
if universe == 'multiverse':
	self.universe = ''
]:
	i: 
	o: 47(t), 86(f)

nname: 0
n 0(None)[self.universe = universe
if universe == 'multiverse':
	self.universe = ''
if universe != 'multiverse':
	if not name:
		pass
self.get_marker_params = ('', {})
self._name = name
self.menu = None
self.list_owned = []
self._refresh()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef26cc>}
nname: 0
n 0(None)[return self.name
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9ecc>}
nname: 0
n 0(None)[return bool(len(self))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f8c>}
nname: 0
n 0(None)[return int(self.wymedia_resource['recursiveCount'])
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9e6c>}
nname: 0
n 0(None)[self.wymedia_resource = get_marker_list(*self.get_marker_params)
self.size = int(self.wymedia_resource.get('size', 0))
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef220c>}
nname: 0
n 0(None)[return False
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9e8c>}
nname: 62
n 62(None)[values = {'items': len(self), 'size': bytes_to_human(self.size)}
return pattern % values
]:
	i: 9(), 37()
	o: 

nname: 37
n 37(None)[pattern = ngettext('%(items)i item', '%(items)i items', len(self))
]:
	i: 0(f)
	o: 62()

nname: 9
n 9(None)[pattern = ngettext('%(items)i item, %(size)s', '%(items)i items, %(size)s', len(self))
]:
	i: 0(t)
	o: 62()

nname: 0
n 0(self.size)[]:
	i: 
	o: 9(t), 37(f)

nname: 0
n 0(None)[if self.size:
	pattern = ngettext('%(items)i item, %(size)s', '%(items)i items, %(size)s', len(self))
else:
	pattern = ngettext('%(items)i item', '%(items)i items', len(self))
values = {'items': len(self), 'size': bytes_to_human(self.size)}
return pattern % values
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef23cc>}
nname: 136
n 136(None)[self._refresh()
return None
]:
	i: 30(), 100(), 114(), 134(AE)
	o: 

nname: 134
n 134(None)[]:
	i: 104(f)
	o: 136(AE)

nname: 114
n 114(None)[item.menu._error_spawner()
]:
	i: 104(t)
	o: 136()

nname: 104
n 104(<dummy_ex3> EXC_MATCH UnmarkableError)[]:
	i: 50(except)
	o: 114(t), 134(f)

nname: 100
n 100(None)[]:
	i: 85(), 99()
	o: 136()

nname: 99
n 99(None)[]:
	i: 54(f)
	o: 100()

nname: 85
n 85(None)[res['marked'] = '1'
]:
	i: 54(t)
	o: 100()

nname: 54
n 54(self._name is None)[marker_list_add(self.wymedia_resource, res)
]:
	i: 50(try)
	o: 85(t), 99(f)

nname: 50
n 50(None)[]:
	i: 0(f)
	o: 54(try), 104(except)

nname: 30
n 30(None)[log.error('%s is not from wymedia !!', item)
]:
	i: 0(t)
	o: 136()

nname: 0
n 0(res is None)[res = getattr(item, 'wymedia_resource', None)
]:
	i: 
	o: 30(t), 50(f)

nname: 136
n 136(None)[self._refresh()
return None
]:
	i: 30(), 104(), 50()
	o: 

nname: 104
n 104(None)[except UnmarkableError:
	item.menu._error_spawner()
]:
	i: 50()
	o: 136()

nname: 136
n 136(None)[self._refresh()
return None
]:
	i: 30(), 104(), 50()
	o: 

nname: 50
n 50(None)[try:
	marker_list_add(self.wymedia_resource, res)
	if self._name is None:
		res['marked'] = '1'
]:
	i: 0(f)
	o: 136(), 104()

nname: 30
n 30(None)[log.error('%s is not from wymedia !!', item)
]:
	i: 0(t)
	o: 136()

nname: 0
n 0(res is None)[res = getattr(item, 'wymedia_resource', None)
]:
	i: 
	o: 30(t), 50(f)

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef27ac>, 104: <unpyclib.structure.node instance at 0x9ef2f6c>, 136: <unpyclib.structure.node instance at 0x9ef2f4c>, 50: <unpyclib.structure.node instance at 0x9ef2e6c>, 30: <unpyclib.structure.node instance at 0x9ef2a4c>}
nname: 71
n 71(None)[]:
	i: 3(), 49(), 69(AE)
	o: 

nname: 69
n 69(None)[]:
	i: 39(f)
	o: 71(AE)

nname: 49
n 49(None)[item.menu._error_spawner()
]:
	i: 39(t)
	o: 71()

nname: 39
n 39(<dummy_ex3> EXC_MATCH UnmarkableError)[]:
	i: 0(except)
	o: 49(t), 69(f)

nname: 3
n 3(None)[marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
]:
	i: 0(try)
	o: 71()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 39(except)

nname: 39
n 39(None)[except UnmarkableError:
	item.menu._error_spawner()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
]:
	i: 
	o: 39()

nname: 0
n 0(None)[try:
	marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
except UnmarkableError:
	item.menu._error_spawner()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef29ac>}
nname: 74
n 74(None)[self._refresh()
return None
]:
	i: 30(), 50()
	o: 

nname: 50
n 50(None)[marker_list_remove(self.wymedia_resource, res)
del res['marked']
]:
	i: 0(f)
	o: 74()

nname: 30
n 30(None)[log.error('%s is not from wymedia !!', item)
]:
	i: 0(t)
	o: 74()

nname: 0
n 0(res is None)[res = getattr(item, 'wymedia_resource', None)
]:
	i: 
	o: 30(t), 50(f)

nname: 0
n 0(None)[res = getattr(item, 'wymedia_resource', None)
if res is None:
	log.error('%s is not from wymedia !!', item)
else:
	marker_list_remove(self.wymedia_resource, res)
	del res['marked']
self._refresh()
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef212c>}
nname: 0
n 0(None)[marker_list_remove(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f2c>}
nname: 46
n 46(None)[return WindowedItemList(self, menu=self.menu, universe=self.universe)
]:
	i: 3(), 21(), 44(AE)
	o: 

nname: 44
n 44(None)[]:
	i: 11(f)
	o: 46(AE)

nname: 21
n 21(None)[from pygui.item.mediaitem.progressive_result import WindowedItemList
]:
	i: 11(t)
	o: 46()

nname: 11
n 11(<dummy_ex3> EXC_MATCH NameError)[]:
	i: 0(except)
	o: 21(t), 44(f)

nname: 3
n 3(None)[WindowedItemList
]:
	i: 0(try)
	o: 46()

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 11(except)

nname: 11
n 11(None)[except NameError:
	from pygui.item.mediaitem.progressive_result import WindowedItemList
return WindowedItemList(self, menu=self.menu, universe=self.universe)
]:
	i: 0()
	o: 

nname: 0
n 0(None)[try:
	WindowedItemList
]:
	i: 
	o: 11()

nname: 0
n 0(None)[try:
	WindowedItemList
except NameError:
	from pygui.item.mediaitem.progressive_result import WindowedItemList
return WindowedItemList(self, menu=self.menu, universe=self.universe)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef20ac>}
nname: 0
n 0(None)[marker_list_clear(self.wymedia_resource)
self._refresh()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f0c>}
nname: 0
n 0(None)[object_remove(self.wymedia_resource, {'universe': self.universe})
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9fac>}
nname: 0
n 0(None)[marker_list_copy_start(self.wymedia_resource, container.wymedia_resource)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9e4c>}
nname: 0
n 0(None)[marker_list_copy_cancel(self.wymedia_resource)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f4c>}
nname: 0
n 0(None)[return marker_list_copy_status(self.wymedia_resource)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f2c>}
nname: 0
n 0(None)[playlist_create_from_markerlist(self.wymedia_resource, container.wymedia_resource, name)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9eac>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f4c>}
nname: 0
n 0(None)[]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9dcc>}
nname: 64
n 64(None)[from pygui.item.mediaitem.core import WMedia2MMIObjects
wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]
]:
	i: 47(), 63()
	o: 

nname: 63
n 63(None)[]:
	i: 35(f)
	o: 64()

nname: 47
n 47(None)[name = _('Now Playing')
]:
	i: 35(t)
	o: 64()

nname: 35
n 35(name is None)[]:
	i: 12(), 25()
	o: 47(t), 63(f)

nname: 25
n 25(None)[parent = container.wymedia_resource
]:
	i: 0(f)
	o: 35()

nname: 12
n 12(None)[parent = get_root()
]:
	i: 0(t)
	o: 35()

nname: 0
n 0(container is None)[]:
	i: 
	o: 12(t), 25(f)

nname: 64
n 64(None)[from pygui.item.mediaitem.core import WMedia2MMIObjects
wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]
]:
	i: 0()
	o: 

nname: 0
n 0(None)[if container is None:
	parent = get_root()
else:
	parent = container.wymedia_resource
if name is None:
	name = _('Now Playing')
]:
	i: 
	o: 64()

nname: 0
n 0(None)[if container is None:
	parent = get_root()
else:
	parent = container.wymedia_resource
if name is None:
	name = _('Now Playing')
from pygui.item.mediaitem.core import WMedia2MMIObjects
wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef2b0c>}
nname: 0
n 0(None)[playlist_append_marker_list(Markerlist.now_playing.wymedia_resource, self.wymedia_resource)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9f8c>}
nname: 84
n 84(None)[Markerlist.now_playing.play(starts_with)
return None
]:
	i: 22(JA), 36(), 68()
	o: 

nname: 68
n 68(None)[Markerlist.now_playing = self.get_playlist()
]:
	i: 0(f)
	o: 84()

nname: 36
n 36(None)[Markerlist.now_playing.vfs_delete()
Markerlist.now_playing = self.get_playlist()
]:
	i: 15(f)
	o: 84()

nname: 22
n 22(None)[self.append_to_now_playing()
]:
	i: 15(t)
	o: 84(JA)

nname: 15
n 15(append_to_npl)[]:
	i: 0(t)
	o: 22(t), 36(f)

nname: 0
n 0(Markerlist.now_playing is not None)[]:
	i: 
	o: 15(t), 68(f)

nname: 0
n 0(None)[if Markerlist.now_playing is not None:
	if append_to_npl:
		self.append_to_now_playing()
	else:
		Markerlist.now_playing.vfs_delete()
		Markerlist.now_playing = self.get_playlist()
else:
	Markerlist.now_playing = self.get_playlist()
Markerlist.now_playing.play(starts_with)
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef2b0c>}
nname: 75
n 75(None)[return None
]:
	i: 34(), 38(), 74(AE)
	o: 

nname: 38
n 38(None)[log.error('Unable to read %s[%s]' % (self, name))
PRINT_EXCEPTION()
]:
	i: 0(except)
	o: 75()

nname: 34
n 34(None)[]:
	i: 18(), 33()
	o: 75()

nname: 33
n 33(None)[]:
	i: 3(f)
	o: 34()

nname: 18
n 18(None)[return self.wymedia_resource[name]
]:
	i: 3(t)
	o: 34()

nname: 3
n 3(self.wymedia_resource is not None)[]:
	i: 0(try)
	o: 18(t), 33(f)

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 38(except)

nname: 75
n 75(None)[return None
]:
	i: 38(), 0()
	o: 

nname: 38
n 38(None)[except:
	log.error('Unable to read %s[%s]' % (self, name))
	PRINT_EXCEPTION()
]:
	i: 0()
	o: 75()

nname: 75
n 75(None)[return None
]:
	i: 38(), 0()
	o: 

nname: 0
n 0(None)[try:
	if self.wymedia_resource is not None:
		return self.wymedia_resource[name]
]:
	i: 
	o: 75(), 38()

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef234c>, 38: <unpyclib.structure.node instance at 0x9ef258c>, 75: <unpyclib.structure.node instance at 0x9ef21ac>}
nname: 112
n 112(None)[return None
]:
	i: 71(), 75(), 111(AE)
	o: 

nname: 75
n 75(None)[log.error('Unable to write %s[%s]' % (self, name))
PRINT_EXCEPTION()
]:
	i: 0(except)
	o: 112()

nname: 71
n 71(None)[]:
	i: 18(), 70()
	o: 112()

nname: 70
n 70(None)[]:
	i: 3(f)
	o: 71()

nname: 18
n 18(None)[self.wymedia_resource[name] = value
set_metadata({'id': self.wymedia_resource['id'], name: value})
]:
	i: 3(t)
	o: 71()

nname: 3
n 3(self.wymedia_resource is not None)[]:
	i: 0(try)
	o: 18(t), 70(f)

nname: 0
n 0(None)[]:
	i: 
	o: 3(try), 75(except)

nname: 112
n 112(None)[return None
]:
	i: 75(), 0()
	o: 

nname: 75
n 75(None)[except:
	log.error('Unable to write %s[%s]' % (self, name))
	PRINT_EXCEPTION()
]:
	i: 0()
	o: 112()

nname: 112
n 112(None)[return None
]:
	i: 75(), 0()
	o: 

nname: 0
n 0(None)[try:
	if self.wymedia_resource is not None:
		self.wymedia_resource[name] = value
		set_metadata({'id': self.wymedia_resource['id'], name: value})
]:
	i: 
	o: 112(), 75()

self.nodes: {0: <unpyclib.structure.node instance at 0x9ef26cc>, 75: <unpyclib.structure.node instance at 0x9ef220c>, 112: <unpyclib.structure.node instance at 0x9ef2d2c>}
nname: 6
n 6(None)[__doc__ = "\n    This class handles marked items. It interacts\n    directly with 'Wymedia' module to retrieve data about them.\n    Each universe has an unique markerlist\n    "
display_type = None
type = 'marker'
now_playing = None
def __init__(self, universe, name=None):
	self.universe = universe
	if universe == 'multiverse':
		self.universe = ''
	if universe != 'multiverse':
		if not name:
			pass
	self.get_marker_params = ('', {})
	self._name = name
	self.menu = None
	self.list_owned = []
	self._refresh()
	return None

def __id__(self):
	return self.name

def __nonzero__(self):
	return bool(len(self))

def __len__(self):
	return int(self.wymedia_resource['recursiveCount'])

def _refresh(self):
	self.wymedia_resource = get_marker_list(*self.get_marker_params)
	self.size = int(self.wymedia_resource.get('size', 0))

def is_marked(self):
	return False

def get_human_size(self):
	if self.size:
		pattern = ngettext('%(items)i item, %(size)s', '%(items)i items, %(size)s', len(self))
	else:
		pattern = ngettext('%(items)i item', '%(items)i items', len(self))
	values = {'items': len(self), 'size': bytes_to_human(self.size)}
	return pattern % values

name = property(get_human_size)
def add_item(self, item):
	res = getattr(item, 'wymedia_resource', None)

def add_ref_item(self, ref):
	try:
		marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
	except UnmarkableError:
		item.menu._error_spawner()

def del_item(self, item):
	res = getattr(item, 'wymedia_resource', None)
	if res is None:
		log.error('%s is not from wymedia !!', item)
	else:
		marker_list_remove(self.wymedia_resource, res)
		del res['marked']
	self._refresh()
	return None

def del_ref_item(self, ref):
	marker_list_remove(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})

def browse(self):
	try:
		WindowedItemList
	except NameError:
		from pygui.item.mediaitem.progressive_result import WindowedItemList
	return WindowedItemList(self, menu=self.menu, universe=self.universe)

def clear(self):
	marker_list_clear(self.wymedia_resource)
	self._refresh()

def vfs_delete(self):
	object_remove(self.wymedia_resource, {'universe': self.universe})

def vfs_copy_to(self, container):
	marker_list_copy_start(self.wymedia_resource, container.wymedia_resource)

def vfs_copy_cancel(self):
	marker_list_copy_cancel(self.wymedia_resource)

def vfs_copy_status(self):
	return marker_list_copy_status(self.wymedia_resource)

def create_playlist(self, container, name):
	playlist_create_from_markerlist(self.wymedia_resource, container.wymedia_resource, name)

def lock(self, val):
	pass

def hide(self, val):
	pass

def get_playlist(self, container=None, name=None):
	if container is None:
		parent = get_root()
	else:
		parent = container.wymedia_resource
	if name is None:
		name = _('Now Playing')
	from pygui.item.mediaitem.core import WMedia2MMIObjects
	wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
	return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]

def append_to_now_playing(self):
	playlist_append_marker_list(Markerlist.now_playing.wymedia_resource, self.wymedia_resource)

def play(self, starts_with=None, append_to_npl=False):
	if Markerlist.now_playing is not None:
		if append_to_npl:
			self.append_to_now_playing()
		else:
			Markerlist.now_playing.vfs_delete()
			Markerlist.now_playing = self.get_playlist()
	else:
		Markerlist.now_playing = self.get_playlist()
	Markerlist.now_playing.play(starts_with)
	return None

def __getitem__(self, name):
	try:
		if self.wymedia_resource is not None:
			return self.wymedia_resource[name]

def __setitem__(self, name, value):
	try:
		if self.wymedia_resource is not None:
			self.wymedia_resource[name] = value
			set_metadata({'id': self.wymedia_resource['id'], name: value})

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0x9ee9bec>}
nname: 0
n 0(None)[self._mlists = dict()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee8b4c>}
nname: 184
n 184(None)[return self._mlists[universe]
]:
	i: 158(), 183()
	o: 

nname: 183
n 183(None)[]:
	i: 68(f)
	o: 184()

nname: 158
n 158(None)[self._mlists[universe] = Markerlist(real_universe, name)
]:
	i: 117(), 145()
	o: 184()

nname: 145
n 145(None)[name = None
real_universe = universe
]:
	i: 105(f)
	o: 158()

nname: 117
n 117(None)[real_universe, name = universe.split(':', 1)
]:
	i: 105(t)
	o: 158()

nname: 105
n 105(':' in universe)[]:
	i: 96(), 104()
	o: 117(t), 145(f)

nname: 104
n 104(None)[]:
	i: 83(f)
	o: 105()

nname: 96
n 96(None)[return None
]:
	i: 83(t)
	o: 105()

nname: 83
n 83(universe == 'main')[]:
	i: 68(t)
	o: 96(t), 104(f)

nname: 68
n 68(universe not in self._mlists)[]:
	i: 60(), 67()
	o: 83(t), 183(f)

nname: 67
n 67(None)[]:
	i: 0(f)
	o: 68()

nname: 60
n 60(None)[del _[1]
return self._mlists.values()
]:
	i: 12(AF), 56()
	o: 68()

nname: 56
n 56(None)[]:
	i: 36(f), 45()
	o: 60()

nname: 45
n 45(None)[continue
]:
	i: 36(t)
	o: 56()

nname: 36
n 36(f)[for f in self._mlists.values():
]:
	i: 12(for)
	o: 45(t), 56(f)

nname: 12
n 12(None)[]:
	i: 0(t)
	o: 36(for), 60(AF)

nname: 0
n 0(universe == '*')[]:
	i: 
	o: 12(t), 67(f)

nname: 184
n 184(None)[return self._mlists[universe]
]:
	i: 158(), 68(f)
	o: 

nname: 158
n 158(None)[self._mlists[universe] = Markerlist(real_universe, name)
]:
	i: 83()
	o: 184()

nname: 83
n 83(None)[if universe == 'main':
	return None
if ':' in universe:
	real_universe, name = universe.split(':', 1)
else:
	name = None
	real_universe = universe
]:
	i: 68(t)
	o: 158()

nname: 68
n 68(universe not in self._mlists)[]:
	i: 60(), 0(f)
	o: 83(t), 184(f)

nname: 60
n 60(None)[del _[1]
return self._mlists.values()
]:
	i: 12(AF), 36()
	o: 68()

nname: 36
n 36(None)[for f in self._mlists.values():
if f:
	continue
]:
	i: 12(for)
	o: 60()

nname: 12
n 12(None)[]:
	i: 0(t)
	o: 36(for), 60(AF)

nname: 0
n 0(universe == '*')[]:
	i: 
	o: 12(t), 68(f)

nname: 184
n 184(None)[return self._mlists[universe]
]:
	i: 83(), 68(f)
	o: 

nname: 83
n 83(None)[if universe == 'main':
	return None
if ':' in universe:
	real_universe, name = universe.split(':', 1)
else:
	name = None
	real_universe = universe
self._mlists[universe] = Markerlist(real_universe, name)
]:
	i: 68(t)
	o: 184()

nname: 68
n 68(universe not in self._mlists)[]:
	i: 60(), 0(f)
	o: 83(t), 184(f)

nname: 60
n 60(None)[del _[1]
return self._mlists.values()
]:
	i: 12(AF), 36()
	o: 68()

nname: 36
n 36(None)[for f in self._mlists.values():
if f:
	continue
]:
	i: 12(for)
	o: 60()

nname: 12
n 12(None)[]:
	i: 0(t)
	o: 36(for), 60(AF)

nname: 0
n 0(universe == '*')[]:
	i: 
	o: 12(t), 68(f)

nname: 68
n 68(None)[if universe not in self._mlists:
	if universe == 'main':
		return None
	if ':' in universe:
		real_universe, name = universe.split(':', 1)
	else:
		name = None
		real_universe = universe
	self._mlists[universe] = Markerlist(real_universe, name)
return self._mlists[universe]
]:
	i: 60(), 0(f)
	o: 

nname: 60
n 60(None)[del _[1]
return self._mlists.values()
]:
	i: 12(AF), 36()
	o: 68()

nname: 36
n 36(None)[for f in self._mlists.values():
if f:
	continue
]:
	i: 12(for)
	o: 60()

nname: 12
n 12(None)[]:
	i: 0(t)
	o: 36(for), 60(AF)

nname: 0
n 0(universe == '*')[]:
	i: 
	o: 12(t), 68(f)

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee9aec>, 36: <unpyclib.structure.node instance at 0x9ee960c>, 12: <unpyclib.structure.node instance at 0x9ee958c>, 68: <unpyclib.structure.node instance at 0x9ee950c>, 60: <unpyclib.structure.node instance at 0x9ee976c>}
nname: 0
n 0(None)[return self._mlists.itervalues()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee8b2c>}
nname: 24
n 24(None)[return self._mlists[universe]
]:
	i: 15(), 23()
	o: 

nname: 23
n 23(None)[]:
	i: 0(f)
	o: 24()

nname: 15
n 15(None)[return None
]:
	i: 0(t)
	o: 24()

nname: 0
n 0(universe not in self._mlists)[]:
	i: 
	o: 15(t), 23(f)

nname: 0
n 0(None)[if universe not in self._mlists:
	return None
return self._mlists[universe]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee8c6c>}
nname: 31
n 31(None)[]:
	i: 0(AL), 30()
	o: 

nname: 30
n 30(None)[]:
	i: 3(AF), 14()
	o: 31()

nname: 14
n 14(None)[for ml in self['*']:
ml.clear()
]:
	i: 3(for)
	o: 30()

nname: 3
n 3(None)[]:
	i: 0(loop)
	o: 14(for), 30(AF)

nname: 0
n 0(None)[]:
	i: 
	o: 3(loop), 31(AL)

nname: 31
n 31(None)[]:
	i: 14()
	o: 

nname: 14
n 14(None)[for ml in self['*']:
	ml.clear()
]:
	i: 0(for)
	o: 31()

nname: 0
n 0(None)[]:
	i: 
	o: 14(for)

nname: 31
n 31(None)[]:
	i: 0()
	o: 

nname: 0
n 0(None)[for ml in self['*']:
	ml.clear()
]:
	i: 
	o: 31()

nname: 0
n 0(None)[for ml in self['*']:
	ml.clear()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee8e6c>}
nname: 6
n 6(None)[__doc__ = "This class acts as a proxy to access each universes' markerlist"
__metaclass__ = MetaSingleton
def __init__(self):
	self._mlists = dict()

def __getitem__(self, universe):
	pass

def __iter__(self):
	return self._mlists.itervalues()

def get(self, universe):
	if universe not in self._mlists:
		return None
	return self._mlists[universe]

def clear_all_markerlists(self):
	for ml in self['*']:
		ml.clear()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0x9ee890c>}
nname: 6
n 6(None)[]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0x9ee836c>}
nname: 6
n 6(None)[]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0x9ee82ec>}
nname: 76
n 76(None)[return fl
]:
	i: 62(), 75()
	o: 

nname: 75
n 75(None)[]:
	i: 24&49(f)
	o: 76()

nname: 62
n 62(None)[fl.menu = menu
]:
	i: 24&49(t)
	o: 76()

nname: 24&49
n 24&49(menu and fl is not None)[fl = markerlists()[item.menu.universe]
]:
	i: 15(), 23()
	o: 62(t), 75(f)

nname: 23
n 23(None)[]:
	i: 0(f)
	o: 24&49()

nname: 15
n 15(None)[return None
]:
	i: 0(t)
	o: 24&49()

nname: 0
n 0(item.menu is None)[]:
	i: 
	o: 15(t), 23(f)

nname: 76
n 76(None)[return fl
]:
	i: 0()
	o: 

nname: 0
n 0(None)[if item.menu is None:
	return None
fl = markerlists()[item.menu.universe]
if menu and fl is not None:
	fl.menu = menu
]:
	i: 
	o: 76()

nname: 0
n 0(None)[if item.menu is None:
	return None
fl = markerlists()[item.menu.universe]
if menu and fl is not None:
	fl.menu = menu
return fl
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ee8ccc>}
nname: 0
n 0(None)[from __future__ import absolute_import
from wymedia.wmplus import get_marker_list, marker_list_clear, get_root, object_remove, marker_list_remove, marker_list_add, playlist_create_from_markerlist, playlist_append_marker_list, marker_list_copy_start, marker_list_copy_cancel, marker_list_copy_status, set_metadata, RemoveError, UnmarkableError
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from peewee.formatters import bytes_to_human
from pygui.menu import UNIVERSE_NAME_DICT
log = GET_LOGGER(__name__)
class Markerlist(object):
	__doc__ = "\n    This class handles marked items. It interacts\n    directly with 'Wymedia' module to retrieve data about them.\n    Each universe has an unique markerlist\n    "
	display_type = None
	type = 'marker'
	now_playing = None
	def __init__(self, universe, name=None):
		self.universe = universe
		if universe == 'multiverse':
			self.universe = ''
		if universe != 'multiverse':
			if not name:
				pass
		self.get_marker_params = ('', {})
		self._name = name
		self.menu = None
		self.list_owned = []
		self._refresh()
		return None

	def __id__(self):
		return self.name

	def __nonzero__(self):
		return bool(len(self))

	def __len__(self):
		return int(self.wymedia_resource['recursiveCount'])

	def _refresh(self):
		self.wymedia_resource = get_marker_list(*self.get_marker_params)
		self.size = int(self.wymedia_resource.get('size', 0))

	def is_marked(self):
		return False

	def get_human_size(self):
		if self.size:
			pattern = ngettext('%(items)i item, %(size)s', '%(items)i items, %(size)s', len(self))
		else:
			pattern = ngettext('%(items)i item', '%(items)i items', len(self))
		values = {'items': len(self), 'size': bytes_to_human(self.size)}
		return pattern % values

	name = property(get_human_size)
	def add_item(self, item):
		res = getattr(item, 'wymedia_resource', None)

	def add_ref_item(self, ref):
		try:
			marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
		except UnmarkableError:
			item.menu._error_spawner()

	def del_item(self, item):
		res = getattr(item, 'wymedia_resource', None)
		if res is None:
			log.error('%s is not from wymedia !!', item)
		else:
			marker_list_remove(self.wymedia_resource, res)
			del res['marked']
		self._refresh()
		return None

	def del_ref_item(self, ref):
		marker_list_remove(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})

	def browse(self):
		try:
			WindowedItemList
		except NameError:
			from pygui.item.mediaitem.progressive_result import WindowedItemList
		return WindowedItemList(self, menu=self.menu, universe=self.universe)

	def clear(self):
		marker_list_clear(self.wymedia_resource)
		self._refresh()

	def vfs_delete(self):
		object_remove(self.wymedia_resource, {'universe': self.universe})

	def vfs_copy_to(self, container):
		marker_list_copy_start(self.wymedia_resource, container.wymedia_resource)

	def vfs_copy_cancel(self):
		marker_list_copy_cancel(self.wymedia_resource)

	def vfs_copy_status(self):
		return marker_list_copy_status(self.wymedia_resource)

	def create_playlist(self, container, name):
		playlist_create_from_markerlist(self.wymedia_resource, container.wymedia_resource, name)

	def lock(self, val):
		pass

	def hide(self, val):
		pass

	def get_playlist(self, container=None, name=None):
		if container is None:
			parent = get_root()
		else:
			parent = container.wymedia_resource
		if name is None:
			name = _('Now Playing')
		from pygui.item.mediaitem.core import WMedia2MMIObjects
		wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
		return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]

	def append_to_now_playing(self):
		playlist_append_marker_list(Markerlist.now_playing.wymedia_resource, self.wymedia_resource)

	def play(self, starts_with=None, append_to_npl=False):
		if Markerlist.now_playing is not None:
			if append_to_npl:
				self.append_to_now_playing()
			else:
				Markerlist.now_playing.vfs_delete()
				Markerlist.now_playing = self.get_playlist()
		else:
			Markerlist.now_playing = self.get_playlist()
		Markerlist.now_playing.play(starts_with)
		return None

	def __getitem__(self, name):
		try:
			if self.wymedia_resource is not None:
				return self.wymedia_resource[name]

	def __setitem__(self, name, value):
		try:
			if self.wymedia_resource is not None:
				self.wymedia_resource[name] = value
				set_metadata({'id': self.wymedia_resource['id'], name: value})



from peewee.misc_utils import MetaSingleton
class MarkerlistAccessor(object):
	__doc__ = "This class acts as a proxy to access each universes' markerlist"
	__metaclass__ = MetaSingleton
	def __init__(self):
		self._mlists = dict()

	def __getitem__(self, universe):
		pass

	def __iter__(self):
		return self._mlists.itervalues()

	def get(self, universe):
		if universe not in self._mlists:
			return None
		return self._mlists[universe]

	def clear_all_markerlists(self):
		for ml in self['*']:
			ml.clear()



class IncompatibleMarkerlistItems(Exception):
	pass

class IncompatibleMarkerlistDestination(Exception):
	pass

markerlists = MarkerlistAccessor
def get_marker_from_item(item, menu=None):
	if item.menu is None:
		return None
	fl = markerlists()[item.menu.universe]
	if menu and fl is not None:
		fl.menu = menu
	return fl

from .actions import actions
__all__ = ['markerlists', 'Markerlist', 'actions', 'get_marker_from_item', 'IncompatibleMarkerlistItems', 'IncompatibleMarkerlistDestination']
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0x9ed9f2c>}
from __future__ import absolute_import
from wymedia.wmplus import get_marker_list, marker_list_clear, get_root, object_remove, marker_list_remove, marker_list_add, playlist_create_from_markerlist, playlist_append_marker_list, marker_list_copy_start, marker_list_copy_cancel, marker_list_copy_status, set_metadata, RemoveError, UnmarkableError
from peewee.debug import GET_LOGGER, PRINT_EXCEPTION
from peewee.formatters import bytes_to_human
from pygui.menu import UNIVERSE_NAME_DICT
log = GET_LOGGER(__name__)
class Markerlist(object):
	__doc__ = "\n    This class handles marked items. It interacts\n    directly with 'Wymedia' module to retrieve data about them.\n    Each universe has an unique markerlist\n    "
	display_type = None
	type = 'marker'
	now_playing = None
	def __init__(self, universe, name=None):
		self.universe = universe
		if universe == 'multiverse':
			self.universe = ''
		if universe != 'multiverse':
			if not name:
				pass
		self.get_marker_params = ('', {})
		self._name = name
		self.menu = None
		self.list_owned = []
		self._refresh()
		return None

	def __id__(self):
		return self.name

	def __nonzero__(self):
		return bool(len(self))

	def __len__(self):
		return int(self.wymedia_resource['recursiveCount'])

	def _refresh(self):
		self.wymedia_resource = get_marker_list(*self.get_marker_params)
		self.size = int(self.wymedia_resource.get('size', 0))

	def is_marked(self):
		return False

	def get_human_size(self):
		if self.size:
			pattern = ngettext('%(items)i item, %(size)s', '%(items)i items, %(size)s', len(self))
		else:
			pattern = ngettext('%(items)i item', '%(items)i items', len(self))
		values = {'items': len(self), 'size': bytes_to_human(self.size)}
		return pattern % values

	name = property(get_human_size)
	def add_item(self, item):
		res = getattr(item, 'wymedia_resource', None)

	def add_ref_item(self, ref):
		try:
			marker_list_add(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})
		except UnmarkableError:
			item.menu._error_spawner()

	def del_item(self, item):
		res = getattr(item, 'wymedia_resource', None)
		if res is None:
			log.error('%s is not from wymedia !!', item)
		else:
			marker_list_remove(self.wymedia_resource, res)
			del res['marked']
		self._refresh()
		return None

	def del_ref_item(self, ref):
		marker_list_remove(self.wymedia_resource, {'id': ref.wymedia_resource['refid']})

	def browse(self):
		try:
			WindowedItemList
		except NameError:
			from pygui.item.mediaitem.progressive_result import WindowedItemList
		return WindowedItemList(self, menu=self.menu, universe=self.universe)

	def clear(self):
		marker_list_clear(self.wymedia_resource)
		self._refresh()

	def vfs_delete(self):
		object_remove(self.wymedia_resource, {'universe': self.universe})

	def vfs_copy_to(self, container):
		marker_list_copy_start(self.wymedia_resource, container.wymedia_resource)

	def vfs_copy_cancel(self):
		marker_list_copy_cancel(self.wymedia_resource)

	def vfs_copy_status(self):
		return marker_list_copy_status(self.wymedia_resource)

	def create_playlist(self, container, name):
		playlist_create_from_markerlist(self.wymedia_resource, container.wymedia_resource, name)

	def lock(self, val):
		pass

	def hide(self, val):
		pass

	def get_playlist(self, container=None, name=None):
		if container is None:
			parent = get_root()
		else:
			parent = container.wymedia_resource
		if name is None:
			name = _('Now Playing')
		from pygui.item.mediaitem.core import WMedia2MMIObjects
		wmedia_pls = playlist_create_from_markerlist(self.wymedia_resource, parent, name)
		return list(WMedia2MMIObjects([wmedia_pls], self.menu, self))[0]

	def append_to_now_playing(self):
		playlist_append_marker_list(Markerlist.now_playing.wymedia_resource, self.wymedia_resource)

	def play(self, starts_with=None, append_to_npl=False):
		if Markerlist.now_playing is not None:
			if append_to_npl:
				self.append_to_now_playing()
			else:
				Markerlist.now_playing.vfs_delete()
				Markerlist.now_playing = self.get_playlist()
		else:
			Markerlist.now_playing = self.get_playlist()
		Markerlist.now_playing.play(starts_with)
		return None

	def __getitem__(self, name):
		try:
			if self.wymedia_resource is not None:
				return self.wymedia_resource[name]

	def __setitem__(self, name, value):
		try:
			if self.wymedia_resource is not None:
				self.wymedia_resource[name] = value
				set_metadata({'id': self.wymedia_resource['id'], name: value})



from peewee.misc_utils import MetaSingleton
class MarkerlistAccessor(object):
	__doc__ = "This class acts as a proxy to access each universes' markerlist"
	__metaclass__ = MetaSingleton
	def __init__(self):
		self._mlists = dict()

	def __getitem__(self, universe):
		pass

	def __iter__(self):
		return self._mlists.itervalues()

	def get(self, universe):
		if universe not in self._mlists:
			return None
		return self._mlists[universe]

	def clear_all_markerlists(self):
		for ml in self['*']:
			ml.clear()



class IncompatibleMarkerlistItems(Exception):
	pass

class IncompatibleMarkerlistDestination(Exception):
	pass

markerlists = MarkerlistAccessor
def get_marker_from_item(item, menu=None):
	if item.menu is None:
		return None
	fl = markerlists()[item.menu.universe]
	if menu and fl is not None:
		fl.menu = menu
	return fl

from .actions import actions
__all__ = ['markerlists', 'Markerlist', 'actions', 'get_marker_from_item', 'IncompatibleMarkerlistItems', 'IncompatibleMarkerlistDestination']
